﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Pokemon
{
    public abstract class Zombie : Unit
    {

        protected int _speed;

        protected Zombie(Game game, Blank owner, Vector2 position) 
            : base(game, owner, position)
        {            
        }

        public override void Update(GameTime gameTime)
        {
            //Rectangle r = new Rectangle((int)_owner.Position.X, (int)_owner.Position.Y, (int)_owner.Size.X, (int)_owner.Size.Y);
            Rectangle r = new Rectangle((int)_owner.Position.X, 0, 800, 480);
            Point point = GetCenterPoint();
            if (!r.Contains(point))
                _owner.OnZombieMoveOut(this);
            base.Update(gameTime);
        }

        //public override Point GetCenterPoint()
        //{
        //    int index = GetUnitStateIndex();            
        //    Vector2 v = new Vector2(Size.X - _textures[index].CenterPoint.X + Position.X, _textures[index].CenterPoint.Y + Position.Y);
        //    return new Point((int)v.X, (int)v.Y);
        //}

        public override void NormalizePosition()
        {

        }

        public void CreateBoom()
        {
            Vector2 blankPosition = _owner.Position;            
            Boom b = new Boom(Game, new Vector2(_textures[GetUnitStateIndex()].CenterPoint.X + _position.X, blankPosition.Y + 15));
            var x = b.Position.X - b.Sprite[b.FrameIndex].CenterPoint.X;
            b.Position = new Vector2(x, b.Position.Y);
            BoomManager boomManager = Game.Services.GetService(typeof (BoomManager)) as BoomManager;
            boomManager.Add(b);
        }
    }
}
